<?php

namespace app\admin\model\user;

use think\Model;


class User extends Model
{

    

    

    // 表名
    protected $name = 'user';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'gender_text',
        'income_text',
        'house_text',
        'parents_text',
        'marry_text',
        'kids_text',
        'is_car_text',
        'is_divorce_text',
        'is_kids_text',
        'kids_live_text',
        'create_time_text',
        'is_group_text',
        'is_cook_text',
        'prevtime_text',
        'logintime_text',
        'jointime_text',
        'examined_text'
    ];
    

    
    public function getGenderList()
    {
        return ['1' => __('Gender 1'), '2' => __('Gender 2')];
    }

    public function getIncomeList()
    {
        return ['1' => __('Income 1'), '2' => __('Income 2'), '3' => __('Income 3'), '4' => __('Income 4'), '5' => __('Income 5'), '6' => __('Income 6'), '7' => __('Income 7')];
    }

    public function getHouseList()
    {
        return ['1' => __('House 1'), '2' => __('House 2')];
    }

    public function getParentsList()
    {
        return ['1' => __('Parents 1'), '2' => __('Parents 2')];
    }

    public function getMarryList()
    {
        return ['0' => __('Marry 0'), '1' => __('Marry 1'), '2' => __('Marry 2'), '3' => __('Marry 3')];
    }

    public function getKidsList()
    {
        return ['1' => __('Kids 1'), '2' => __('Kids 2'), '3' => __('Kids 3')];
    }

    public function getIsCarList()
    {
        return ['1' => __('Is_car 1'), '2' => __('Is_car 2')];
    }

    public function getIsDivorceList()
    {
        return ['1' => __('Is_divorce 1'), '2' => __('Is_divorce 2')];
    }

    public function getIsKidsList()
    {
        return ['1' => __('Is_kids 1'), '2' => __('Is_kids 2'), '3' => __('Is_kids 3'), '4' => __('Is_kids 4')];
    }

    public function getKidsLiveList()
    {
        return ['1' => __('Kids_live 1'), '2' => __('Kids_live 2'), '3' => __('Kids_live 3'), '4' => __('Kids_live 4'), '5' => __('Kids_live 5')];
    }

    public function getIsGroupList()
    {
        return ['1' => __('Is_group 1'), '2' => __('Is_group 2')];
    }

    public function getIsCookList()
    {
        return ['1' => __('Is_cook 1'), '2' => __('Is_cook 2')];
    }

    public function getExaminedList()
    {
        return ['1' => __('Examined 1'), '2' => __('Examined 2'), '3' => __('Examined 3')];
    }


    public function getGenderTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
        $list = $this->getGenderList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIncomeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['income']) ? $data['income'] : '');
        $list = $this->getIncomeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getHouseTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['house']) ? $data['house'] : '');
        $list = $this->getHouseList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getParentsTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['parents']) ? $data['parents'] : '');
        $list = $this->getParentsList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getMarryTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['marry']) ? $data['marry'] : '');
        $list = $this->getMarryList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getKidsTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['kids']) ? $data['kids'] : '');
        $list = $this->getKidsList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsCarTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_car']) ? $data['is_car'] : '');
        $list = $this->getIsCarList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsDivorceTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_divorce']) ? $data['is_divorce'] : '');
        $list = $this->getIsDivorceList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsKidsTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_kids']) ? $data['is_kids'] : '');
        $list = $this->getIsKidsList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getKidsLiveTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['kids_live']) ? $data['kids_live'] : '');
        $list = $this->getKidsLiveList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getIsGroupTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_group']) ? $data['is_group'] : '');
        $list = $this->getIsGroupList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsCookTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_cook']) ? $data['is_cook'] : '');
        $list = $this->getIsCookList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPrevtimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['prevtime']) ? $data['prevtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getLogintimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['logintime']) ? $data['logintime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getJointimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['jointime']) ? $data['jointime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getExaminedTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['examined']) ? $data['examined'] : '');
        $list = $this->getExaminedList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    protected function setCreateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setPrevtimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setLogintimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setJointimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
